import axios from '../request'

// 获取数据字典
export function getDict(type): Promise<any> {
  return axios.get('/api/v1/dict_detail/options', {
    params: { dictinary_code: type }
  })
}
// 获取上传签名
export function getSignUrl(filename: any): Promise<any> {
  return axios.post(`/api/v1/common/upload/sign_url?filename=${filename}&timeout=1200`, {})
}

// 上传接口
export function uploadFile(uploadUrl: string, arrayBuf: ArrayBuffer) {
  if (uploadUrl == '') {
    console.log('no uploadUrl: ' + uploadUrl)
    return
  }

  return axios({
    method: 'put',
    url: uploadUrl,
    headers: {
      'Content-Type': ''
    },
    data: arrayBuf
  })
}

// 获取数据字典
export function aiIconGenerateApi(data): Promise<any> {
  return axios.post('/api/v1/ai/icon_generate', data)
}

export type imageContentCheckApiPropsType = {
  file_name: string
  data: string
}

// // 图片内容合规校验接口
// export function imageContentCheckApi(data: imageContentCheckApiPropsType): Promise<any> {
//   return axios.post('/api/v1/ai/image_check', data)
// }

// 获取用户权限list
export function getPermissionsApi(): Promise<any> {
  return axios.get('/api/v1/permission/allow_codes')
}
